﻿using Caliburn.Micro;
using myapp.Events;
using myapp.Events.ViewModel;
using myapp.Instances;
using myapp.ViewModels;
using myappcore.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace myapp.ViewModels
{
    /// <summary>
    /// Function ViewModel
    /// </summary>
    public class FunctionViewModel : IBaseContentViewModel
    {
        #region Attribute

        /// <summary>
        /// Action ViewModel
        /// </summary>
        private Screen _actionViewModel;

        private Function _function;
        #endregion

        #region Properties

        /// <summary>
        /// Data of possition
        /// </summary>
        public Function Function
        {
            get
            {
                return _function;
            }
            set
            {
                if (null != value)
                {
                    _function = value;
                    NotifyOfPropertyChange(() => Function);
                }
            }
        }

        /// <summary>
        /// Action ViewModel
        /// </summary>
        public Screen ActionViewModel
        {
            get
            {
                return _actionViewModel;
            }
            set
            {
                if (null != value)
                {
                    _actionViewModel = value;
                    NotifyOfPropertyChange(() => ActionViewModel);
                }
            }
        }

        #endregion

        #region Contructor
        public FunctionViewModel()
        {
            CurrentColor = MainInstance.Instance.ColorConfig.FunctionGroupNormal;
        }
        #endregion

        #region Method
        public void FunctionSelected()
        {
            MainInstance.Instance.EventAggregator.Publish(new ViewModelFunctionSelectedEvent()
            {
                FunctionViewModel = this
            });

            MainInstance.Instance.EventAggregator.Publish(new ViewModelFunctionActiveShowEvent()
            {
                IsShow = false
            });
        }
        #endregion
    }
}
